import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductLevelConfigVO, ProductLevelConfigForm, ProductLevelConfigQuery } from '@/api/config/productLevelConfig/types';

/**
 * 查询产品评级配置列表
 * @param query
 * @returns {*}
 */

export const listProductLevelConfig = (query?: ProductLevelConfigQuery): AxiosPromise<ProductLevelConfigVO[]> => {
  return request({
    url: '/config/productLevelConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品评级配置详细
 * @param id
 */
export const getProductLevelConfig = (id: string | number): AxiosPromise<ProductLevelConfigVO> => {
  return request({
    url: '/config/productLevelConfig/' + id,
    method: 'get'
  });
};

/**
 * 新增产品评级配置
 * @param data
 */
export const addProductLevelConfig = (data: ProductLevelConfigForm) => {
  return request({
    url: '/config/productLevelConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品评级配置
 * @param data
 */
export const updateProductLevelConfig = (data: ProductLevelConfigForm) => {
  return request({
    url: '/config/productLevelConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品评级配置
 * @param id
 */
export const delProductLevelConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/config/productLevelConfig/' + id,
    method: 'delete'
  });
};
